usbip: network: Fix unaligned member access
authorBen Hutchings <ben@decadent.org.uk>
Sun, 18 Aug 2019 15:15:26 +0000 (16:15 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Sun, 19 Jan 2020 09:22:58 +0000 (09:22 +0000)
commit31267c7b2daa5d6efbcfc2b93725308ecefcef61
tree975b192f43c4010d12b54c83c1be2070d2dde3a5
parent82d82cb4e236022ec154d337196ab60b0e99499a
usbip: network: Fix unaligned member access

Bug-Debian: https://bugs.debian.org/925766

gcc 9 warns:

usbip_network.c: In function ‘usbip_net_pack_usb_device’:
usbip_network.c:79:32: error: taking address of packed member of ‘struct usbip_usb_device’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
   79 |  usbip_net_pack_uint32_t(pack, &udev->busnum);
      |                                ^~~~~~~~~~~~~

and similarly for other calls to usbip_net_pack_uint{16,32}_t().

These fields are unaligned because they are declared as part of a
packed structure.  Functions operating on the structure will use the
appropriate accessors for unaligned data if necessary, but there
doesn't seem to be a way to declare functions as taking a pointer
to a unaligned scalar.

Instead, change these functions to take a pointer of type void * and
to memcpy() the unaligned value in and out of a local variable.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name usbip-network-fix-unaligned-member-access.patch
tools/usb/usbip/src/usbip_network.c
tools/usb/usbip/src/usbip_network.h